package com.kjc.demo.basic.algorithm;

public class SelectSort {
	
	public static int[] selectSort(int[] arr) {
		for(int i=0; i<arr.length -1 ;i++) {
			int min = i;
			for(int j= i+1; j<arr.length;j++) {
				if(arr[i] > arr[j]) {
					min = j;
				}
			}
			if(min != i) {
				int temp = arr[i];
				arr[i] = arr[min];
				arr[min] = temp;
			}
		}
		return arr;
	}
	
	public static void main(String[] args) {
		int[] arr = new int[] {2,3,5,6,8,1,10,9};
		arr = selectSort(arr);
		for(int i : arr) {
			System.out.print(i+" ");
		}
	}
	
}
